var titleToNumber = function(columnTitle) {
    var sum = 0;
    var carry = 1;
    var i = columnTitle.length;
    while(i > 0){
        sum += (columnTitle[i - 1].charCodeAt() - 65) * carry
        carry *= 26;
        i--;
    }
    return sum;
};

var a = titleToNumber('A')
console.log(a);
